@page "/Admin"
@using Microsoft.AspNetCore.Authorization
@rendermode InteractiveServer
@attribute [Authorize]

<PageTitle>Change Password</PageTitle>

<MudText Typo="Typo.h5">Change Password</MudText>

<MudCard Class="mx-auto my-4" Style="max-width: 500px;">
    <MudCardContent>
        @if (!string.IsNullOrEmpty(_errorMessage))
        {
            <MudAlert Severity="Severity.Error" Class="mb-3">@_errorMessage</MudAlert>
        }
        @if (!string.IsNullOrEmpty(_successMessage))
        {
            <MudAlert Severity="Severity.Success" Class="mb-3">@_successMessage</MudAlert>
        }
        <MudTextField @bind-Value="_username" Label="New User Name" Required="true" RequiredError="Username cannot be empty" />
        <MudTextField @bind-Value="_currentPassword" Label="Current Password" Required="true" RequiredError="Password cannot be empty"
                      InputType="@_currentPasswordInput" Adornment="Adornment.End"
                      AdornmentIcon="@_currentPasswordInputIcon" OnAdornmentClick="ToggleCurrentPasswordVisibility" />
        <MudTextField @bind-Value="_newPassword" Label="New Password" Required="true" RequiredError="Password cannot be empty"
                      InputType="@_passwordInput" Adornment="Adornment.End"
                      AdornmentIcon="@_passwordInputIcon" OnAdornmentClick="TogglePasswordVisibility" />
        <MudTextField @bind-Value="_confirmPassword" Label="Confirm Password" Required="true" RequiredError="Password cannot be empty"
                      InputType="@_passwordInput" Adornment="Adornment.End"
                      AdornmentIcon="@_passwordInputIcon" OnAdornmentClick="TogglePasswordVisibility" />
    </MudCardContent>
    <MudCardActions>
        <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="ChangePasswordAsync"
                   Class="ml-auto">Submit</MudButton>
    </MudCardActions>
</MudCard>

<MudThemeProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
